package com.tide.crm.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.tide.crm.model.CustomerContacts;

@Mapper
public interface CustomerContactsDao {

    @Select("select * from customer_contacts t where t.id = #{id}")
    CustomerContacts getById(Long id);

    @Delete("delete from customer_contacts where id = #{id}")
    int delete(Long id);

    int update(CustomerContacts customerContacts);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into customer_contacts(customer_id, post_code, post_name, full_name, comtact_number, comtact_phone, email, creater, create_date, modifyer, modify_date) values(#{customerId}, #{postCode}, #{postName}, #{fullName}, #{comtactNumber}, #{comtactPhone}, #{email}, #{creater}, #{createDate}, #{modifyer}, #{modifyDate})")
    int save(CustomerContacts customerContacts);
    
    int count(@Param("params") Map<String, Object> params);

    List<CustomerContacts> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    List<CustomerContacts> findListByCusId(Long customId);

    void deleteByCusId(Long customerId);
}
